package com.lyubia.shop.order.config;

import com.lyubia.shop.order.interceptor.OrderLoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class OrderConfig implements WebMvcConfigurer {

    @Resource
    private OrderLoginInterceptor orderLoginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(orderLoginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/bootstrap/**",
                        "/css/**","/dist/**","/images/**",
                        "/img/**","/js/**","/plugins/**")
                .excludePathPatterns("/toLogin")
                .excludePathPatterns("/image/**")
                .excludePathPatterns("/login")
                .excludePathPatterns("/logout");
    }

}
